package com.lanhai.webservice.controller;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.rmi.RemoteException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import com.lanhai.webservice.proxy.IService1Proxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lanhai.webservice.entity.WebLogInfo;
import com.lanhai.webservice.service.WebLogInfoService;

@RestController
public class WebServiceController {

	@Autowired
	private WebLogInfoService webLogInfoService;

	@RequestMapping("/webservicetest")
	public String[] test() throws RemoteException {
		String[] arrRFID = new String[] { "", "", "", "", "", "A", "B", "C", "D", "E" };
		IService1Proxy iService1Proxy = new IService1Proxy();
		String[] strings = iService1Proxy.sendRFIDInfoToMES(arrRFID);

		Arrays.asList(strings).forEach(System.out::println);

		System.out.println("111");
		List<WebLogInfo> selectall = webLogInfoService.selectall();
		selectall.forEach(System.out::println);
		return strings;
	}

	@RequestMapping("/inserttest")
	public String inserttest(){
		WebLogInfo webLogInfo = new WebLogInfo();
		webLogInfo.setId(UUID.randomUUID().toString());
		webLogInfo.setProcedurenum(0);
		webLogInfo.setIssuccee("1");
		int insert = webLogInfoService.insert(webLogInfo);
		return insert+"";
	}

	/**
	 * 主动删除3天前的日志
	 * @return 删除数据的数量
	 */
	@RequestMapping("/deleteLog")
	public String deleteLog(){
		int count = webLogInfoService.deleteTimeOutLog();
		return count+"";
	}

}
